package de.distMLP.data;

import org.apache.hadoop.io.Text;

import de.distMLP.train.Training_Helper;
import de.mlp_distributed.mlp.math.mahout.Vector;

public class TrainingExample {

	private Vector featureVector = null;
	private Vector targetVector = null;

	public TrainingExample() {
		super();
	}

	public TrainingExample(final Text data, final int featureVectorSize, final int targetVectorSize) {
		this.featureVector = Training_Helper.getFeatureVectorFromTrainingsdata(data, featureVectorSize);
		this.targetVector = Training_Helper.getTargetVectorFromTrainingsdata(data, targetVectorSize);
	}

	public TrainingExample(final Vector featureVector, final Vector targetVector) {
		this.featureVector = featureVector;
		this.targetVector = targetVector;
	}

	public void assign(final Vector featureVector, final Vector targetVector) {
		if (this.featureVector != null) {
			this.featureVector.assign(featureVector);
		} else {
			this.featureVector = featureVector;
		}
		if (this.targetVector != null) {
			this.targetVector.assign(targetVector);
		} else {
			this.targetVector = targetVector;
		}
	}

	public void copy(final TrainingExample other) {
		this.assign(other.getFeatureVector().clone(), other.getTargetVector().clone());
	}

	public Vector getFeatureVector() {
		return this.featureVector;
	}

	public Vector getTargetVector() {
		return this.targetVector;
	}
}
